import request from "../../utils/request";
import { get } from "@/utils/request";
import { type LoginData, type LoginResult, type LoginResultModel } from "./type";
import { useCryptoStore} from "@/store";


export const loginApi =async (data: LoginData) => {
 
  data.pwd=await useCryptoStore().doEncrypt(data.pwd);

  return request<any, LoginResult>({
    url: `/api/auth/login`,
    method: "post",
    data: data,
  });
  
};

export const getUserInfo = () => {
  return get<null, LoginResultModel>("/api/account/getUserInfo");
};

export const getPublicKey = () => {
  return get<null, string>("/api/auth/publicKey");
};

